package org.wangp.gateway.oa.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.oauth2.provider.ClientDetails;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;

/**
 * @author wangpeng (๑•ᴗ•๑)
 * @date 2021/10/20 14:44
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ClientDetail implements ClientDetails {
	private static final long serialVersionUID = 1481390991855896367L;

	private Long cdId;

	private String clientId;

	private String resourceIds;

	private String clientSecret;

	private String scope;

	private Integer accessTokenValiditySeconds;

	private Integer refreshTokenValiditySeconds;

	private Boolean isAutoApprove;

	@Override
	public String getClientId() {
		return this.clientId;
	}

	@Override
	public Set<String> getResourceIds() {
		return Collections.singleton(this.resourceIds);
	}

	@Override
	public boolean isSecretRequired() {
		return false;
	}

	@Override
	public String getClientSecret() {
		return this.clientSecret;
	}

	@Override
	public boolean isScoped() {
		return false;
	}

	@Override
	public Set<String> getScope() {
		return Collections.singleton(this.scope);
	}

	@Override
	public Set<String> getAuthorizedGrantTypes() {
		return null;
	}

	@Override
	public Set<String> getRegisteredRedirectUri() {
		return null;
	}

	@Override
	public Collection<GrantedAuthority> getAuthorities() {
		return Collections.emptyList();
	}

	@Override
	public Integer getAccessTokenValiditySeconds() {
		return null;
	}

	@Override
	public Integer getRefreshTokenValiditySeconds() {
		return null;
	}

	@Override
	public boolean isAutoApprove(final String scope) {
		return false;
	}

	@Override
	public Map<String, Object> getAdditionalInformation() {
		return Collections.emptyMap();
	}
}
